package com.banding.algorithm;

import com.banding.util.TimeUtils;

public class RecursionPractice {
    public static void main(String[] args) {
        int i = 4;
        calcFactorialTime(i);
        calcFibTime(i);
        calcisPowerOfTwo(i);
    }

    public static void calcFactorialTime(int i) {
        Long startTime = TimeUtils.getTimeMills();
        int res = Recursion.factorial(i);
        Long endTime = TimeUtils.getTimeMills();
        System.out.printf("factorial(%d) = %d\n",i,res);
        System.out.printf("factorial(%d)运行时间为：%dms\n", i, endTime - startTime);
    }

    public static void calcFibTime(int i) {
        Long startTime2 = TimeUtils.getTimeMills();
        int res = Recursion.fib(i);
        Long endTime2 = TimeUtils.getTimeMills();
        System.out.printf("fib(%d) = %d\n",i,res);
        System.out.printf("fib(%d)运行时间为：%dms\n", i, endTime2 - startTime2);
    }

    public static void calcisPowerOfTwo(int i){
        System.out.println(Recursion.isPowerOfTwo(i));
    }
}
